# Maintainer: Christian Hesse <mail@eworm.de>

pkgname=wireguard-lts
pkgver=1.0.20210124
pkgrel=8
pkgdesc='Wireguard module for LTS Kernel'
url='https://www.wireguard.com/'
arch=('x86_64')
license=('GPL')
makedepends=('linux-lts-headers' "wireguard-dkms=$pkgver")
conflicts=('wireguard-dkms')
provides=('WIREGUARD-MODULE')

build() {
    _kernver="$(</usr/src/linux-lts/version)"

    fakeroot dkms build --dkmstree "$srcdir" -m wireguard/$pkgver -k $_kernver
}

package() {
  depends=('linux-lts')

  _kernver="$(</usr/src/linux-lts/version)"

  install -Dt "$pkgdir/usr/lib/modules/$_kernver/extramodules" -m0644 \
    wireguard/${pkgver}/$_kernver/$CARCH/module/*

  # compress each module individually
  find "$pkgdir" -name '*.ko' -exec xz -T1 {} +
}
